USE [BMIG_MENSUAL_POST_CADENA]

 -- creating the store procedure
IF EXISTS (SELECT name 
	   FROM   sysobjects 
	   WHERE  name = 'WASP_M0009_DROP_TABLAS'
	   AND 	  type = 'P') 
	DROP PROCEDURE [dbo].[WASP_M0009_DROP_TABLAS]
GO

create PROCEDURE [dbo].[WASP_M0009_DROP_TABLAS]AS
begin    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_codigos_seguros_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ingreso_produccion_codigos_seguros_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_valores_seguros_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ingreso_produccion_valores_seguros_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_seguros_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ingreso_produccion_seguros_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_numero_telefono_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ingreso_produccion_numero_telefono_ant]
    end
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produccion_temp_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ing_produccion_temp_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produccion_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ing_produccion_ant]
    end
        
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_seguro_vida_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ingreso_produccion_seguro_vida_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_seguro_asisten_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ingreso_produccion_seguro_asisten_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_seguro_degrav_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ingreso_produccion_seguro_degrav_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produccion_total_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ing_produccion_total_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_UF_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ingreso_produccion_UF_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Produccion_Cuotas_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[Produccion_Cuotas_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produc_val_seg_aux_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ing_produc_val_seg_aux_ant]
    end
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produc_cod_seg_aux_ant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    begin
      drop table [dbo].[ing_produc_cod_seg_aux_ant]
    end
end    
